package com.snow.wechat;

import cn.hutool.json.JSONObject;
import com.snow.annotation.RequireLogin;
import com.snow.wechat.component.WeChatComponent;
import com.snow.view.WebResponse;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@Slf4j
@RestController
@AllArgsConstructor
@RequestMapping("/wechat")
public class WechatController {

    WeChatComponent weChatComponent;

    @RequireLogin(false)
    @PostMapping("/jsCode2session")
    public WebResponse<JSONObject> jsCode2session(@RequestBody JSONObject params) {
        return WebResponse.success(weChatComponent.jsCode2session(params.getStr("code")));
    }



}
